package site.teamo.biu.flink.web.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import site.teamo.biu.flink.web.entity.OperatorDO;
import site.teamo.biu.flink.web.mapper.FunctionMapper;
import site.teamo.biu.flink.web.service.OperatorService;

import java.util.List;

/**
 * @author haocongshun
 * @date 2023/11/06 11:11:21
 */
@Service
public class OperatorServiceImpl extends ServiceImpl<FunctionMapper, OperatorDO> implements OperatorService {

    @Override
    public List<OperatorDO> list(String keyword, String type) {
        if (StrUtil.isNotBlank(keyword)) {
            String key = "%" + keyword + "%";
            return list(new LambdaQueryWrapper<OperatorDO>()
                    .eq(OperatorDO::getType, type)
                    .and(qw -> qw.like(OperatorDO::getName, key)
                            .or()
                            .like(OperatorDO::getClassName, key)));
        } else {
            return list(new LambdaQueryWrapper<OperatorDO>()
                    .eq(OperatorDO::getType, type));
        }
    }
}
